<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 300px;
        height: 300px;
        background-color: #f00;
      }
      .box2 {
        width: 30px;
        height: 30px;
        background-color: #0f0;
      }
    </style>
  </head>
  <body>
    <!-- 
        鼠标事件修饰符
        .stop:阻止冒泡
        .prevent:阻止默认行为
        键盘事件修饰符
        .enter:按下回车才触发
     -->
    <div id="app">
      <div class="box" @click="boxClick">
        <div class="box2" @click.stop.prevent="box2Click"></div>
        <div>121212</div>
      </div>
      <a href="http://www.baidu.com" @click.prevent="aClick">111111</a>
      <input type="text" @keyup.enter="keyupEvent" />
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data: {},
        methods: {
          boxClick () {
            console.log('boxClick')
          },
          box2Click (e) {
            // e.stopPropagation()
            console.log('box2Click')
          },
          aClick (e) {
            // e.preventDefault()
            alert('aclick')
            console.log('aClick')
          },
          keyupEvent () {
            console.log('keyupEvent')
          }
        }
      })
    </script>
  </body>
</html>
